//
//  VC2AlertView.swift
//  ChapterAll
//
//  Created by Kevin on 2020/4/22.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class VC2AlertView: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let alert = UIAlertController(title: "提示", message: "\n提示内容", preferredStyle: .alert)
        alert.addTextField { (textfield) in
            textfield.placeholder = "please input name"
        }
        alert.addAction(UIAlertAction(title: "取消", style: .cancel, handler: { (action) in
            print("cancel")
        }))
        alert.addAction(UIAlertAction(title: "确定", style: .default, handler: { (action) in
            print("ok \(String(describing: alert.textFields?.first?.text))")
        }))
        alert.addAction(UIAlertAction(title: "警告", style: .destructive, handler: { (action) in
            print("warm")
        }))
        present(alert, animated: true, completion: nil)
    }
    
}
